<?php


namespace app\backend\service;


use app\common\model\CountDay;
use app\common\RootCountService;

class CountDayService extends RootCountService
{

    public function lists(array $params)
    {
        return $this->getData((new CountDay()), $params);
    }

    /**
     * 手动输入
     * @param array $params
     * @return string[]
     */
    public function editRowField(array $params)
    {
        $data = [];

        # 次日留存、7日留存：双击该位置，手动输入
        if (!empty($params['next_day_save'])) {
            $data['next_day_save'] = $params['next_day_save'];
        }
        if (!empty($params['seven_day_save'])) {
            $data['seven_day_save'] = $params['seven_day_save'];
        }

        # 广告收益
        if (!empty($params['adv_income'])) {
            $data['adv_income'] = $params['adv_income'];
        }
        # 提现金额
        if (!empty($params['withdraw'])) {
            $data['withdraw'] = $params['withdraw'];
        }
        # 推广成功
        if (!empty($params['promote_success'])) {
            $data['promote_success'] = $params['promote_success'];
        }
        if (!empty($params['gross_profit'])) {
            $data['gross_profit'] = $params['gross_profit'];
        }

        if (count($data) > 0) {
            $res = CountDay::update($data, ['id' => $params['id']]);
            if ($res) {
                return ['msg' => '修改成功'];
            }
        }
        return ['msg' => '修改失败'];
    }
}